const areaModel = require('../models/areas.model')
const logger = require('../utils/logger')
class AreaService {
  areas = areaModel
  findAll () {
    return this.areas.find({ deleted: false })
  }
  findOne (id) {
    return this.areas.find({ deleted: false, _id: id })
  }
  updateOne (id, data) {
    return this.areas.findOneAndUpdate({ _id: id }, data)
  }
  deleteOne (id) {
    return this.areas.findOneAndRemove({ _id: id })
  }
  async addOne (doc) {
    // TODO check doc
    logger.info('report created ', doc)
    return await this.areas.create(doc)
  }
}

module.exports = AreaService